import time

import requests
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import os
from inter.commonKeys import sysKey

# # 会话管理
# session = requests.session()
#
# session.headers["content-type"] ='application/x-www-form-urlencoded'
# session.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
# session.headers['x-zse-83'] = '3_2.0'
#
# result = session.post('https://www.zhihu.com/udid')
# print(result.text)
#
# result = session.get('https://www.zhihu.com/api/v3/oauth/captcha?lang=en')
# print(result.text)
#
#
# # 400：一般都是头参数问题
# result = session.post('https://www.zhihu.com/api/v3/oauth/sign_in',data='aR79k4U0cT2tXqYq8LPG6vHmxq2pkLnmtbSBDgg9kLtxgeSmhbfGiqX1jbfVoG398LF0gQN0cT2tuqYq8LkMQbwGivwOgUxGw9e0g4e8kCV92vgBzh3qk4R92LkYFhVGwqoVJbCGST2tEqx9BLkBEJXmST2tXqYhZUS8eDC8FBtxg7Fqm4O8nCL8DU3m2LPB8vSG2gC8QBtxg_VBXbP1UvLKQ_2pkLkBXgxGEJeGsgHm2LfBpwNmkveMcBtxgTxqYM20oQu0o7YpoH2qs0tqk698oTYpQMtBM8xyoALyNw2xnCYyYLt924_BkC3VUbSBtq3qk478gGpucUO1PD3ZJCe8Xq2tgqNMsvSMS79hQ82Xo7tyfTYqST9qr_LxgRVmZ9oMgGL1eBtxg_NMwGoM2JXMXq2tguVKKvwGEJHM3BtxgRF0zuFqrH9BrXxpggY8BTxyNguq6X2fS828G8OBFgr8Xq2tHgSVKbOBDBe8')
# print(result.text)


option = webdriver.ChromeOptions()
userfile = os.environ["USERPROFILE"]
option.add_argument("--user-data-dir=%s\\AppData\\Local\\Google\\Chrome\\user data"%userfile)
ex = "./lib/conf/chromedriver.exe"
driver = webdriver.Chrome(options=option,executable_path=ex)

driver.get("https://imgchr.com/")
time.sleep(3)
#driver.find_element_by_xpath("//a[text()='开始上传']").send_keys(r"C:\Users\admin\Desktop\预创建新闻\1.png")

driver.find_element_by_xpath("//input[@type='file' ][1]").send_keys(r"C:\Users\admin\Desktop\预创建新闻\1.png")

time.sleep(3)
driver.find_element_by_xpath("//button[@data-action='upload']").click()







